Zadig 文档
Zadig
教程
博客
论坛
关于
中文英文
Zadig
教程
博客
论坛
关于
Zadig v3.4
Loading...
     编辑文档
     反馈问题
     社区讨论

    本页导航

    构建

    # 从模板创建构建

    请求

    POST /openapi/build?source=template
    
    1

    body 参数说明

    参数名说明类型必填
    name构建名称string是
    project_key项目标识string是
    template_name构建模板名称string是
    target_services服务配置[]TargetService是

    TargetService 参数说明

    参数名说明类型必填
    service_module服务组件名称string是
    service_name服务名称string是
    repo_info代码库信息[]RepoInfo是
    inputs变量信息[]Input是

    RepoInfo 参数说明

    参数名说明类型必填
    codehost_name代码源标识string是
    repo_namespace代码库所属命名空间(组织/个人)string是
    repo_name代码库名称string是
    branch分支信息string是

    Input 参数说明

    参数名说明类型必填
    key变量的键值string是
    value变量的值string是

    body 参数示例

    {
        "name": "demo-build",
        "project_key": "demo",
        "template_name": "demo-template",
        "target_services": [
            {
                "service_module": "aslan",
                "service_name": "zadigx",
                "repo_info": [
                    {
                        "codehost_name": "github-demo",
                        "repo_namespace": "kr-test-org",
                        "repo_name": "zadig",
                        "branch": "main"
                    }
                ],
                "inputs": [
                    {
                        "key": "name",
                        "value": "admin"
                    },
                    {
                      "key": "password",
                      "value": "zadigx"
                    }
                ]
            }
        ]
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29

    返回

    {
      "message": "success"
    }
    
    1
    2
    3

    # 查询构建列表

    请求

    GET /openapi/build?projectKey=<项目标识>&pageNum=<当前页数>&pageSize=<当前页显示条数>
    
    1

    query 参数说明

    参数名类型描述是否必须默认值
    projectKeystring项目标识是无
    pageNumint分页参数-当前页数否1
    pageSizeint分页参数-当前页显示条数否20

    返回说明

    参数名类型描述
    totalint构建模块总数
    builds[]Build构建模块列表

    Build 参数说明

    参数名类型描述
    namestring构建名称
    project_keystring项目标识
    sourcestring构建方式,有以下两种:zadig、jenkins
    update_bystring更新者
    update_timeint更新时间
    target_services[]TargetService服务组件列表

    TargetService 参数说明

    参数名类型描述
    service_namestring服务名称
    service_modulestring服务组件名称

    正常返回

    点击查看
    {
        "total": 2,
        "builds": [
            {
                "name": "s-build",
                "project_key": "lilian-test",
                "source": "zadig",
                "update_by": "admin",
                "update_time": 1686192895,
                "target_services": [
                    {
                        "service_name": "service1",
                        "service_module": "service1"
                    },
                    {
                        "service_name": "service2",
                        "service_module": "service2"
                    }
                ]
            },
            {
                "name": "openapi-build",
                "project_key": "lilian-test",
                "source": "zadig",
                "update_by": "admin",
                "update_time": 1688040721,
                "target_services": [
                    {
                        "service_name": "service1",
                        "service_module": "service1"
                    }
                ]
            }
        ]
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35

    # 获取构建详情

    请求

    GET /openapi/build/:buildName/detail?projectKey=<项目标识>
    
    1

    query 参数说明

    参数名类型描述是否必须默认值
    projectKeystring项目标识是无
    serviceNamestring服务名称是无
    serviceModulestring服务组件名称是无

    路径参数说明

    参数名类型描述是否必须默认值
    buildNamestring构建名称是无

    返回说明

    点击查看
    {
        "project_key": "lilian-test", // 项目标识
        "name": "openapi-build", // 构建名称
        "source": "",	// 构建方式,分别有 zadig,jenkins两种
        "target_services": [	// 服务列表
            {
                "service_name": "service1", // 服务名称
                "service_module": "service1" // 服务组件名称
            }
        ],
        "template_name": "test", // 模板名称
        "update_by": "admin",	// 更新的用户名称
        "update_time": 1690215924, // 更新时间,秒级时间戳
        "repos": [ // 代码源信息
          {
                "source": "gitee", // 有以下几种类型:github、gitlab、gerrit、codehub、gitee、gitee-enterprise、other
                "repo_owner": "liyue326",	// 组织名/用户名
                "repo_name": "hello",	// 代码库名称
                "remote_name": "origin", // Remote name
                "branch": "master",	// 分支名称
            		"address":"https://gitlab.com",	// 代码源
            		"checkout_path":"", // 克隆目录名
            		"submodules":false,	 // 子模块
            },
        ],
        "build_env": { // 构建环境
            "basic_image_id": "63047770931401b9baa6e396",	// 操作系统镜像ID
            "basic_image_label": "ubuntu 20.04",	// 操作系统镜像名称
            "installs": [	// 构建依赖的软件包列表
                {
                    "name": "go",
                    "version": "1.13"
                }
            ]
        },
        "advanced_settings": { // 高级配置
            "cluster_name": "local-20220823144517",	// 集群名称
            "timeout": 60,	// 构建超时时间
            "resource_spec": {	// 集群配置项列表
                "cpu_limit": 1000,
                "memory_limit": 512,
                "gpu_limit": ""
            },
          	"use_host_docker_daemon": false, // 是否使用宿主机docker daemon
            "cache_setting": {	// 缓存配置
                "enabled": false,	// 是否使用自定义工作空间
                "cache_dir": ""	// 自定义工作流空间下的缓存路径
            }	
        },
        "build_script": "#!/bin/bash\nset -e",	// 构建脚本
        "parameters": [	// 自定义变量列表
            {
                "key": "a",
                "value": "1",
                "type": "string",
                "is_credential": false
            }
        ]																	
        "outputs": [	// 输出变量列表
            {
                "name": "IMAGE",
                "description": ""
            },
            {
                "name": "PKG_FILE",
                "description": ""
            },
            {
                "name": "xx",
                "description": ""
            }
        ],
        "post_build": {	// 添加步骤
            "docker_build": {	// 镜像构建配置
                "work_dir": "temp",	// 构建上下文目录
                "docker_file": "temp",	// Dockerfile 的绝对路径
                "build_args": "",	// 构建参数
                "source": "local",	// Dockerfile 来源
                "template_name": ""	// template名称(如果dockerfile来源是模板)
            },
            "object_storage_upload": {	// 文件存储 
                "enabled": true,	// 是否使用工作空间缓存
                "object_storage_id": "63422e0690069fe35f4e62bb",	// sidebarMenu.objectStorage
                "upload_detail": [	// 上传文件配置
                    {
                        "file_path": "test",
                        "abs_file_path": "",
                        "dest_path": "temp"
                    }
                ]
            },
            "file_archive": {	// 二进制包存储
                "file_location": "temp"	// 二进制包存储路径
            },
            "scripts": "#!/bin/bash\nset -e"	// Shell 脚本
        }
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97

    # 删除构建

    请求

    DELETE /openapi/build?name=<构建名称>&projectKey=<项目标识>
    
    1

    query 参数说明

    参数名说明类型必填
    name构建名称string是
    projectKey项目标识string是

    返回说明

    {
      "message": "success"
    }
    
    1
    2
    3

    ← 服务测试→

    资源
    教程
    论坛
    博客
    公司
    关于
    客户故事
    加入我们
    联系我们
    微信扫一扫
    hello@koderover.com

    © 2026 筑栈(上海)信息技术有限公司 沪 ICP 备 19000177 号 - 1

    •  跟随系统
    •  浅色模式
    •  深色模式
    •  阅读模式